package cn.wolfcode.rbac.service.impl;

import cn.wolfcode.rbac.domain.CustomerTraceHistory;
import cn.wolfcode.rbac.domain.CustomerTransfer;
import cn.wolfcode.rbac.mapper.CustomerTraceHistoryMapper;
import cn.wolfcode.rbac.mapper.CustomerTransferMapper;
import cn.wolfcode.rbac.query.QueryObject;
import cn.wolfcode.rbac.service.ICustomerTransferService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerTransferServiceImpl implements ICustomerTransferService {

    @Autowired
    private CustomerTransferMapper mapper;

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<CustomerTransfer> list = mapper.selectCustomerTransfer(qo);
        for (CustomerTransfer ctf:list) {
            ctf.setOperateTime(ctf.getOperateTime().substring(0,(ctf.getOperateTime().length()-2)));
        }
        return new PageInfo(list);
    }

    @Override
    public void saveOrUpdate(CustomerTransfer ctf) {
        this.mapper.insert(ctf);
    }

}
